﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Yz.Base;

namespace Yz.Core.Base
{
    /// <summary>
    /// 所有DBAccess基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class BaseAccess<TEntity> : IDependency where TEntity : BaseEntity
    {
        public IConfigurationProvider AutoMapperConfigProvider { get; set; }

        #region 新增
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual ReturnCode Add(TEntity model, Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task<ReturnCode> AddAsync(TEntity model, Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <param name="whereList"></param>
        /// <returns></returns>
        public virtual ReturnCode Add(TEntity model, List<Expression<Func<TEntity, bool>>> whereList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <param name="whereList"></param>
        /// <returns></returns>
        public virtual async Task<ReturnCode> AddAsync(TEntity model, List<Expression<Func<TEntity, bool>>> whereList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 新增，并返回新增后的model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual TEntity AddGet(TEntity model, Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 新增，并返回新增后的model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task<TEntity> AddGetAsync(TEntity model, Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 新增并返回新增后的值
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="db"></param>
        /// <param name="model"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public virtual TEntity AddGet(TEntity model, List<Expression<Func<TEntity, bool>>> whereList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 新增并返回新增后的值
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="db"></param>
        /// <param name="model"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public virtual async Task<TEntity> AddGetAsync(TEntity model, List<Expression<Func<TEntity, bool>>> whereList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public virtual int BatchAdd(List<TEntity> modelList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public virtual async Task<int> BatchAddAsync(List<TEntity> modelList)
        {
            throw new NotImplementedException();
        }
        #endregion

        #region 删除
        /// <summary>
        /// 根据条件删除信息(单个对象删除)
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public virtual ReturnCode Delete(Expression<Func<TEntity, bool>> where)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据条件删除信息(单个对象删除)
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public virtual async Task<ReturnCode> DeleteAsync(Expression<Func<TEntity, bool>> where)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public virtual int BatchDelete(Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public virtual async Task<int> BatchDeleteAsync(Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }
        #endregion

        #region 更新
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="epsUpdate">需要更新的字段</param>
        /// <param name="where1">当前对象是否存在的条件</param>
        /// <param name="where2">判断对象是否重复的条件</param>
        /// <returns></returns>
        public virtual ReturnCode Update(Expression<Func<TEntity, TEntity>> epsUpdate, Expression<Func<TEntity, bool>> where1 = null, Expression<Func<TEntity, bool>> where2 = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="epsUpdate">需要更新的字段</param>
        /// <param name="where1">当前对象是否存在的条件</param>
        /// <param name="where2">判断对象是否重复的条件</param>
        /// <returns></returns>
        public virtual async Task<ReturnCode> UpdateAsync(Expression<Func<TEntity, TEntity>> epsUpdate, Expression<Func<TEntity, bool>> where1 = null, Expression<Func<TEntity, bool>> where2 = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="epsUpdate"></param>
        /// <param name="where1"></param>
        /// <param name="whereList2"></param>
        /// <returns></returns>
        public virtual ReturnCode Update(Expression<Func<TEntity, TEntity>> epsUpdate, List<Expression<Func<TEntity, bool>>> whereList2, Expression<Func<TEntity, bool>> where1 = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="epsUpdate"></param>
        /// <param name="where1"></param>
        /// <param name="whereList2"></param>
        /// <returns></returns>
        public virtual async Task<ReturnCode> UpdateAsync(Expression<Func<TEntity, TEntity>> epsUpdate, List<Expression<Func<TEntity, bool>>> whereList2, Expression<Func<TEntity, bool>> where1 = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量更新对象（需要更新的内容不一样）
        /// </summary>
        /// <param name="source"></param>
        /// <param name="epsUpdate"></param>
        /// <returns></returns>
        public virtual int BatchUpdate(Expression<Func<TEntity, TEntity>> epsUpdate, List<TEntity> modelList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量更新对象（需要更新的内容不一样）
        /// </summary>
        /// <param name="source"></param>
        /// <param name="epsUpdate"></param>
        /// <returns></returns>
        public virtual async Task<int> BatchUpdateAsync(Expression<Func<TEntity, TEntity>> epsUpdate, List<TEntity> modelList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量更新对象（需要更新的内容一样）
        /// </summary>
        /// <param name="source"></param>
        /// <param name="epsUpdate"></param>
        /// <returns></returns>
        public virtual int BatchUpdate(Expression<Func<TEntity, TEntity>> epsUpdate, Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 批量更新对象（需要更新的内容一样）
        /// </summary>
        /// <param name="source"></param>
        /// <param name="epsUpdate"></param>
        /// <returns></returns>
        public virtual async Task<int> BatchUpdateAsync(Expression<Func<TEntity, TEntity>> epsUpdate, Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }
        #endregion

        #region 查询
        /// <summary>
        /// 根据条件获得所有数量
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public virtual int GetTotal(Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据条件获得所有数量
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public virtual async Task<int> GetTotalAsync(Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public virtual bool IsExist(Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public virtual async Task<bool> IsExistAsync(Expression<Func<TEntity, bool>> where = null)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据条件获得所有数量（如果条件中出现or 改为调用此方法，把or拆成多个条件）
        /// </summary>
        /// <param name="whereList"></param>
        /// <returns></returns>
        public virtual int GetUnionTotal(List<Expression<Func<TEntity, bool>>> whereList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据条件获得所有数量（如果条件中出现or 改为调用此方法，把or拆成多个条件）
        /// </summary>
        /// <param name="whereList"></param>
        /// <returns></returns>
        public virtual async Task<int> GetUnionTotalAsync(List<Expression<Func<TEntity, bool>>> whereList)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据条件获得model
        /// </summary>
        /// <param name="lgnName"></param>
        /// <param name="lgnPwd"></param>
        /// <returns></returns>
        public virtual T GetModel<T>(Expression<Func<TEntity, bool>> where = null, List<ParaOrder<TEntity>> orders = null) where T : ViewModel
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据条件获得model
        /// </summary>
        /// <param name="lgnName"></param>
        /// <param name="lgnPwd"></param>
        /// <returns></returns>
        public virtual async Task<T> GetModelAsync<T>(Expression<Func<TEntity, bool>> where = null, List<ParaOrder<TEntity>> orders = null) where T : ViewModel
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 分页获得信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where"></param>
        /// <param name="paraPage"></param>
        /// <returns></returns>
        public virtual ReturnList<T> GetListByPage<T>(Expression<Func<TEntity, bool>> where = null, ParaPage paraPage = null, List<ParaOrder<TEntity>> orders = null, bool hasTotal = true) where T : ViewModel
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 分页获得信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where"></param>
        /// <param name="paraPage"></param>
        /// <returns></returns>
        public virtual async Task<ReturnList<T>> GetListByPageAsync<T>(Expression<Func<TEntity, bool>> where = null, ParaPage paraPage = null, List<ParaOrder<TEntity>> orders = null, bool hasTotal = true) where T : ViewModel
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 分页获得信息（如果条件中出现or 改为调用此方法，把or拆成多个条件）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="whereList"></param>
        /// <param name="paraPage"></param>
        /// <param name="orders"></param>
        /// <returns></returns>
        public virtual ReturnList<T> GetUnionListByPage<T>(List<Expression<Func<TEntity, bool>>> whereList, ParaPage paraPage = null, List<ParaOrder<TEntity>> orders = null, bool hasTotal = true, bool isOnly = true) where T : ViewModel
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 分页获得信息（如果条件中出现or 改为调用此方法，把or拆成多个条件）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="whereList"></param>
        /// <param name="paraPage"></param>
        /// <param name="orders"></param>
        /// <returns></returns>
        public virtual async Task<ReturnList<T>> GetUnionListByPageAsync<T>(List<Expression<Func<TEntity, bool>>> whereList, ParaPage paraPage = null, List<ParaOrder<TEntity>> orders = null, bool hasTotal = true, bool isOnly = true) where T : ViewModel
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
